
package ebasclient.abstracts.guielements;

import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultComboBoxModel;

/**
 *
 * @author Luca Coraci
 */
public abstract class MyAbstractComboModel<T> extends DefaultComboBoxModel {

    protected List<T> datas = new ArrayList<T>();

    public MyAbstractComboModel(List<T> d) {
        if(d != null){
            this.datas = d;
        }
    }

    @Override
    public T getElementAt(int index) {
        return index == -1 ? null : datas.get(index);
        // return dati.get(index);

    }
    

    @Override
    public int getSize() {
        return datas.size();
    }

    @Override
    @SuppressWarnings("unchecked")
    public T getSelectedItem() {
        return (T)super.getSelectedItem();
    }

    
    public List<T> getDatas()
    {
        return this.datas;
    }



}
